package com.xinzhi.savingpot.userinfo.controller;

import com.xinzhi.savingpot.userinfo.service.impl.LoginServiceImpl;
import com.xinzhi.savingpot.util.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("userinfo")
@Api
public class Logincontroller {

    @Autowired
     private LoginServiceImpl loginService;


    @PostMapping("/login")
    @ApiOperation("手机号密码登录")
    public BaseResponse selectUser(@RequestParam("phone") String phone, @RequestParam("password") String password){

        return loginService.Login(phone,password);
    }


    @PostMapping("/codelogin")
    @ApiOperation("发送验证码")

    public BaseResponse selectcode(@RequestParam("phone") String phone){

        return loginService.sendCode(phone);
    }

    @PostMapping("/denglogin")
    @ApiOperation("验证码登录")

    public BaseResponse xiaoyan(@RequestParam("phone") String phone, @RequestParam("code") String code){

        return loginService.checkCode(phone,code);
    }
}
